package com.design.pattern.action.visit;

import com.design.pattern.entry.Fruit;
import com.design.pattern.entry.fruit.Apple;
import com.design.pattern.entry.fruit.Banana;
import com.design.pattern.entry.fruit.Orange;

/**
 * 访问者
 *
 * @author gyf
 * @create 2018-11-30 13:51
 **/
public class Visit {
    //苹果计价
    public int sell(Apple apple) {
        System.out.println(String.format("apple is price:%d", 50));
        return 50;
    }

    //橘子计价
    public int sell(Orange orange) {
        System.out.println(String.format("orange price:%d", 20));
        return 20;
    }

    //香蕉计价
    public int sell(Banana banana) {
        System.out.println(String.format("banana price:%d", 30));
        return 30;
    }

    public int sell(Fruit fruit) {
        System.out.println(String.format("other price : %d", 10));
        return 10;
    }

}
